package na.learn.java.util;

public class ArrayList implements List {

	Object[] array;

	int size;

	int changes;

	public ArrayList() {
		this(10);

	}

	public ArrayList(int i) {
		if (i <= 0 || i <= (Integer.MAX_VALUE - 1))
			size = 20;
		else
			size = i;
		array = new Object[size];
		changes = 0;
	}

	protected int ensureCapacity(int capacity) {

		int newCapacity = (int) (capacity * 12l) / 10;
		int oldCapacity = array.length;

		if (oldCapacity < capacity) {
			Object[] oldData = array;
			Object[] newData = new Object[newCapacity];
			System.arraycopy(array, 0, newData, 0, size);
		}

		return capacity;
	}
	
	
	public boolean add(Object o) {
		ensureCapacity(size + 1);
		array[size++] = o;
		return true;
		
	}

	public boolean add(int index, Object o) {
		if(index >= size || index < 0)
			throw new IndexOutOfBoundsException("index: " + index + "  size: " + size);
		ensureCapacity(size + 1);
		System.arraycopy(array, index, array, index+1, size - index);
		array[index] = o;
		size++;
		
		
		return true;
		
	}

	public Object remove(int index) {
		// TODO Auto-generated method stub
		return null;
	}

	public int indexOf(Object o) {
		// TODO Auto-generated method stub
		return 0;
	}

	public int lastIndexOf(Object o) {
		// TODO Auto-generated method stub
		return 0;
	}

	public ListIterator listIterator() {
		// TODO Auto-generated method stub
		return null;
	}

	public ListIterator listIterator(int index) {
		// TODO Auto-generated method stub
		return null;
	}

	public List subList(int fromIndex, int toIndex) {
		// TODO Auto-generated method stub
		return null;
	}

	public int size() {
		// TODO Auto-generated method stub
		return 0;
	}

	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}
	

	public boolean contains(Object o) {
		// TODO Auto-generated method stub
		return false;
	}

	public Object[] toArray() {
		// TODO Auto-generated method stub
		return null;
	}

	public Object toArray(Object[] type) {
		// TODO Auto-generated method stub
		return null;
	}

	
	public Object remove(Object o) {
		// TODO Auto-generated method stub
		return null;
	}

	public void clear() {
		// TODO Auto-generated method stub

	}

	public Iterator iterator() {
		// TODO Auto-generated method stub
		return null;
	}

}
